/*
 *  This file is part of LifeBudget - Copyright 2010 Clifton Eaton
 *  ------------------------------------------------------------------
 *  LifeBudget is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  LifeBudget is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with LifeBudget.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.lifebudget.app.client.mvc.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.extjs.gxt.ui.client.data.BaseTreeModel;

/**
 * A PaycheckCalculator contains information regarding paychecks and how funds
 * should be allocated to each different {@link Category}.
 * 
 * Serves as model object to the view as well as a Data Transfer Object and 
 * therefore, meant to be used only in the client code or for communicating 
 * to through GWT RPC.
 */
public class PaycheckCalculator extends BaseTreeModel implements Serializable {
	
	/**
	 * The Interval enum.
	 */
	public enum Interval {
		
		/** The Weekly. */
		Weekly, 
		/** The Biweekly. */
		Biweekly, 
		/** The Monthly. */
		Monthly,	
	}

	/** The category amounts. */
	private List<CategoryAmount> categoryAmounts = new ArrayList<CategoryAmount>();

	/**
	 * Instantiates a new paycheck calculator.
	 */
	public PaycheckCalculator() {
		super();
	}

	/**
	 * Instantiates a new paycheck calculator.
	 *
	 * @param name the name
	 * @param estimatedAmt the estimated amt
	 * @param interval the interval
	 * @param description the description
	 * @param categoryAmounts the category amounts
	 */
	public PaycheckCalculator(String name, double estimatedAmt, Interval interval, String description,
			List<CategoryAmount> categoryAmounts) {
		super();
		setName(name);
		setEstimatedAmt(estimatedAmt);
		setInterval(interval);
		setDescription(description);
		setCategoryAmounts(categoryAmounts);
	}

	/**
	 * Gets the category amounts.
	 *
	 * @return the category amounts
	 */
	public List<CategoryAmount> getCategoryAmounts() {
		return categoryAmounts;
	}

	/**
	 * Gets the description.
	 *
	 * @return the description
	 */
	public String getDescription() {
		return get("description");
	}

	/**
	 * Gets the estimated amt.
	 *
	 * @return the estimated amt
	 */
	public double getEstimatedAmt() {
		return get("estimatedAmt");
	}

	/**
	 * Gets the id.
	 *
	 * @return the id
	 */
	public long getId() {
		return get("id");
	}

	/**
	 * Gets the interval.
	 *
	 * @return the interval
	 */
	public Interval getInterval() {
		return Interval.valueOf((String) get("interval"));
	}

	/**
	 * Gets the name.
	 *
	 * @return the name
	 */
	public String getName() {
		return get("name");
	}

	/**
	 * Sets the category amounts.
	 *
	 * @param categoryAmounts the new category amounts
	 */
	public void setCategoryAmounts(List<CategoryAmount> categoryAmounts) {
		this.categoryAmounts = categoryAmounts;
	}

	/**
	 * Sets the description.
	 *
	 * @param description the new description
	 */
	public void setDescription(String description) {

		set("description", description);
	}

	/**
	 * Sets the estimated amount.
	 *
	 * @param estimatedAmt the new estimated amount
	 */
	public void setEstimatedAmt(double estimatedAmt) {

		set("estimatedAmt", estimatedAmt);
	}

	/**
	 * Sets the id.
	 *
	 * @param id the new id
	 */
	public void setId(long id) {

		set("id", id);
	}

	/**
	 * Sets the interval.
	 *
	 * @param interval the new interval
	 */
	public void setInterval(Interval interval) {

		set("interval", interval.toString());
	}

	/**
	 * Sets the name.
	 *
	 * @param name the new name
	 */
	public void setName(String name) {

		set("name", name);
	}

}
